package com.xiaotu.controller;

import com.xiaotu.common.BaseController;
import com.xiaotu.dto.EndOfGameDto;
import com.xiaotu.service.LevelRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author zhangxiao
 * @create 2022-03-25 9:19
 */
@RequestMapping("levelRule")
@RestController
@CrossOrigin
public class LevelRuleController extends BaseController {

    @Autowired
    private LevelRuleService levelRuleService;

    @GetMapping("getLevelRule")
    public Object getLevelRule() {
        return levelRuleService.getLevelRule();
    }

    /**
     * 对局结束
     *
     * @param endOfGameDto
     * @return
     */
    @PostMapping("endOfGame")
    public Object endOfGame(EndOfGameDto endOfGameDto) {
        return levelRuleService.endOfGame(endOfGameDto);
    }

    /**
     * 计算积分
     *
     * @param selfPlayerId
     * @param gameResult
     * @param isFirstHand
     * @param otherPlayerId
     * @param selfCalculate
     * @param otherCalculate
     * @return
     */
    @GetMapping("calculateIntegral")
    public Object calculateIntegral(Integer selfPlayerId, Double gameResult, boolean isFirstHand, Integer otherPlayerId, Integer selfCalculate, Integer otherCalculate) {
        return levelRuleService.calculateIntegral(selfPlayerId, gameResult, isFirstHand, otherPlayerId, selfCalculate, otherCalculate);
    }

}
